﻿// Copyright (c) egmkang wang. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace XServer.GrainInterfaces
{
    using System.Threading.Tasks;
    using Orleans;
    using Orleans.Concurrency;

    public enum UniqueIDType
    {
        UniqueID_PlayerID   = 0,    //玩家唯一ID
        UniqueID_Union      = 1,    //公会ID
        UniqueID_Mail       = 2,    //邮件
        UniqueID_Battle     = 3,    //战斗
    }

    /// <summary>
    /// 用来生成唯一ID
    /// Grain Key的规则: UniqueIDType_GrainNum
    /// UniqueIDType可以是字符串
    /// GrainNum小于1000
    /// 
    /// WARNING: 不能直接使用这个类, 消耗比较高, 需要使用UniqueIDHelper来间接的获取UniqueID
    /// </summary>
    [Unordered]
    public interface IUniqueIDGrain : IGrainWithStringKey
    {
        /// <summary>
        /// 获取UID
        /// </summary>
        /// <returns>返回一个uid</returns>
        Task<long> GetNewID();

        /// <summary>
        /// 获取一批UID
        /// </summary>
        /// <param name="batch">获取多少个uid</param>
        /// <returns>获取到的第一个uid</returns>
        Task<long> GetBatchNewID(int batch);
    }
}
